package com.yuyi.tool;

import java.security.Principal;
import java.util.Collection;
import java.util.List;

import org.apache.shiro.SecurityUtils;
import org.apache.shiro.session.Session;
import org.apache.shiro.session.mgt.eis.SessionDAO;
import org.apache.shiro.subject.Subject;
import org.springframework.beans.factory.annotation.Autowired;

import com.yuyi.model.KefuDO;

/**
 * 
 * @author wxt <br>
 * 2018年11月31日 下午12:19:18
 */
public class ShiroTool {

	@Autowired
	private static SessionDAO sessionDAO;

	public static Subject getSubjct() {
		return SecurityUtils.getSubject();
	}

	public static KefuDO getKefu() {
		Object object = getSubjct().getPrincipal();
		return (KefuDO) object;
	}

	public static Integer getId() {
		return getKefu().getId();
	}

	public static void logout() {
		getSubjct().logout();
	}

	public static List<Principal> getPrinciples() {
		List<Principal> principals = null;
		@SuppressWarnings("unused")
        Collection<Session> sessions = sessionDAO.getActiveSessions();
		return principals;
	}
}
